<?php
	class ArrayToCSV{
		
		var $path;
		var $array;
		
		function ArrayToCSV($path,$array){
			$this->path = $path;
			$this->array = $array;
		}
		
		function exportToCSV(){
			if(!file_exists($this->path)) {
				$file = @fopen($this->path, 'w');
				if($file === false) throw new Exception("Le fichier ${chemin_fichier} n'a pas pu être créé.");
				$columnNames = array_keys($this->array[0]);
				foreach($columnNames as &$columnName) { 
					$columnName = (is_string($columnName)) ? iconv("UTF-8", "Windows-1252//TRANSLIT", $columnName) : $columnName; 
				}
				fputcsv($file, $columnNames, ';');
				fclose($file);
			}
		}
	}
?>